const Router = require('koa-router')
const sequelize = require('../../core/db')
const m =require('../../middle/auth')

const router = new Router({
  prefix: '/book'
})

router.get('/list', m(2), async ctx => {
  ctx.body = {
    uid: ctx.auth.uid,
    type: ctx.auth.type,
    status: 200,
    msg: 'book成功'
  }
})

// 测试sequelize原始查询
router.get('/like', async ctx => {
  let res = await sequelize.query("SELECT * FROM book", { type: sequelize.QueryTypes.SELECT})
  ctx.body = {
    data: res,
    msg: '原始查询成功'
  }
})


module.exports = router